namespace SinaFinance
{
    using System;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Input;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;

    public partial class Review : UserControl
    {
        //private bool _contentLoaded;
        //internal Canvas canvas;
        //internal Canvas canvas1;
        //internal Rectangle close;
        //internal Border closeborder;
        //internal Storyboard closemouseEnter;
        //internal Storyboard closemouseLeave;
        private string detailInfo = "分时图底部区域保存最近访问过的5种股票. 您可以通过点击股票名称进行详细信息查询，或钩选股票进行涨幅率的比对.";
        //internal Storyboard fmouseEnter;
        private bool isExpend = false;
        //internal Canvas LayoutRoot;
        //internal Path path;
        //internal Path path3;
        //internal Path path4;
        //internal Rectangle rectangle;
        private ShutDownReviewArea removeReviewArea;
        //internal Storyboard starMouseEnter;
        private string summaryInfo = "操作描述";
        //internal TextBlock tblDetailInfo;
        //internal TextBlock tblSummary;
        //internal Rectangle up;
        //internal Border upborder;
        //internal Storyboard upmouseEnter;
        //internal Storyboard upmouseLeave;
        //internal Storyboard winZoomIn;
        //internal Storyboard winZoomOut;

        public event ShutDownReviewArea RemoveReviewArea
        {
            [MethodImpl(MethodImplOptions.Synchronized)] add
            {
                this.removeReviewArea = (ShutDownReviewArea)Delegate.Combine((Delegate)this.removeReviewArea, (Delegate)value);
            }
            [MethodImpl(MethodImplOptions.Synchronized)] remove
            {
                this.removeReviewArea = (ShutDownReviewArea)Delegate.Remove((Delegate)this.removeReviewArea, (Delegate)value);
            }
        }

        public Review()
        {
            this.InitializeComponent();
            base.Loaded += new RoutedEventHandler(this.Review_Loaded);
            this.up.MouseLeftButtonDown += new MouseButtonEventHandler(this.up_MouseLeftButtonDown);
        }

        private void canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.removeReviewArea != null)
            {
                this.removeReviewArea(sender, e);
            }
            this.winZoomOut.Begin();
            this.isExpend = false;
        }

        //[DebuggerNonUserCode]
        //public void InitializeComponent()
        //{
        //    if (!this._contentLoaded)
        //    {
        //        this._contentLoaded = true;
        //        Application.LoadComponent(this, new Uri("/SinaFinance;component/Review.xaml", UriKind.Relative));
        //        this.closemouseEnter = (Storyboard) base.FindName("closemouseEnter");
        //        this.fmouseEnter = (Storyboard) base.FindName("fmouseEnter");
        //        this.upmouseEnter = (Storyboard) base.FindName("upmouseEnter");
        //        this.winZoomIn = (Storyboard) base.FindName("winZoomIn");
        //        this.winZoomOut = (Storyboard) base.FindName("winZoomOut");
        //        this.closemouseLeave = (Storyboard) base.FindName("closemouseLeave");
        //        this.upmouseLeave = (Storyboard) base.FindName("upmouseLeave");
        //        this.starMouseEnter = (Storyboard) base.FindName("starMouseEnter");
        //        this.LayoutRoot = (Canvas) base.FindName("LayoutRoot");
        //        this.canvas1 = (Canvas) base.FindName("canvas1");
        //        this.rectangle = (Rectangle) base.FindName("rectangle");
        //        this.tblDetailInfo = (TextBlock) base.FindName("tblDetailInfo");
        //        this.tblSummary = (TextBlock) base.FindName("tblSummary");
        //        this.path4 = (Path) base.FindName("path4");
        //        this.closeborder = (Border) base.FindName("closeborder");
        //        this.canvas = (Canvas) base.FindName("canvas");
        //        this.path = (Path) base.FindName("path");
        //        this.close = (Rectangle) base.FindName("close");
        //        this.upborder = (Border) base.FindName("upborder");
        //        this.path3 = (Path) base.FindName("path3");
        //        this.up = (Rectangle) base.FindName("up");
        //    }
        //}

        private void Review_Loaded(object sender, RoutedEventArgs e)
        {
            this.up.Cursor = Cursors.Hand;
            this.close.Cursor = Cursors.Hand;
            this.starMouseEnter.Begin();
            this.tblSummary.Text = this.summaryInfo;
            this.tblDetailInfo.Text = string.Empty;
        }

        private void up_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.isExpend)
            {
                this.tblSummary.Text = this.summaryInfo;
                this.tblDetailInfo.Text = string.Empty;
                this.winZoomOut.Begin();
            }
            else
            {
                this.winZoomIn.Begin();
                this.tblSummary.Text = this.detailInfo;
                this.tblDetailInfo.Text = "操作描述";
            }
            this.isExpend = !this.isExpend;
        }

        public string DetailInfo
        {
            get
            {
                return this.detailInfo;
            }
            set
            {
                this.detailInfo = value;
            }
        }

        public string SummaryInfo
        {
            get
            {
                return this.summaryInfo;
            }
            set
            {
                this.summaryInfo = value;
            }
        }

        public delegate void ShutDownReviewArea(object sender, MouseEventArgs e);
    }
}
